/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername(str) {
  const valid_map = ['admin', 'editor']
  return valid_map.indexOf(str.trim()) >= 0
}

export function getParamType(param) {
  const toString = Object.prototype.toString
  return toString.call(param).slice(8, -1)
}

export function validateTypes(param, type) {
  return getParamType(param) === type
}
